(function(a){
    if(a.com){
        if(a.com.stilva){
            a.extend(a.com.stilva,{
                animBackground:{}
            })
        }else{
        a.extend(a.com,{
            stilva:{
                animBackground:{}
        }
        })
}
}else{
    a.com={
        stilva:{
            animBackground:{}
    }
}
}
a.fn.animBackground=function(f,c){
    var b=this;
    var e=/([\d]+)[^\s]+[\s]+([\d]+)[^\s]+/ig;
    if(typeof f!=="number"){
        if(f==="clear"){
            return clearInterval(a.com.stilva.animBackground[b.selector])
            }else{
            return Boolean(a.com.stilva.animBackground[b.selector])
            }
        }
    f=(f)?f*1000:1000;
var d={
    ease:"easeOutExpo",
    x:0,
    y:0,
    onComplete:null,
    override:false
};

return this.each(function(i){
    if(c){
        a.extend(d,c)
        }
        if(a.com.stilva.animBackground[b.selector]){
        clearInterval(a.com.stilva.animBackground[b.selector].intervalID);
        a.com.stilva.animBackground[b.selector].currentTime=(d.override)?a.com.stilva.animBackground[b.selector].currentTime:0
        }else{
        a.com.stilva.animBackground[b.selector]={
            intervalID:null,
            currentTime:0
        }
    }
    var g=(b.css("background-position"))?e.exec(b.css("background-position")):[0,0,0];
    g=(!g||g===null)?[0,0,0]:g;
    var h={
    x:Number(g[1]),
    y:Number(g[2])
    };
    
a.com.stilva.animBackground[b.selector].intervalID=setInterval(function(){
    a.com.stilva.animBackground[b.selector].currentTime+=41;
    b.css("background-position",a.easing[d.ease]("",a.com.stilva.animBackground[b.selector].currentTime,h.x,d.x-h.x,f)+"px "+a.easing[d.ease]("",a.com.stilva.animBackground[b.selector].currentTime,h.y,d.y-h.y,f)+"px");
    if(a.com.stilva.animBackground[b.selector].currentTime>f){
        clearInterval(a.com.stilva.animBackground[b.selector].intervalID);
        a.com.stilva.animBackground[b.selector]=null;
        b.css({
            "background-position":d.x+"px "+d.y+"px"
            });
        if(d.onComplete instanceof Function){
            d.onComplete.call(b)
            }
        }
},41)
})
}
})(jQuery);
var getCSS_TOP="place the css before all css'";
var getCSS_BOTTOM="place the css after all css'";
(function(a){
    a.fn.getCSS=function(c,b,e,f){
        var d=a("<link />");
        switch(b){
            case getCSS_TOP:
                d=d.insertBefore(a("head").find("link").first());
                break;
            case getCSS_BOTTOM:default:
                d=d.insertAfter(a("head").find("link").last())
                }
                a.ajax({
            url:c,
            success:function(g){
                d.attr({
                    rel:"stylesheet",
                    type:"text/css",
                    href:c,
                    media:"all"
                });
                if(e){
                    e(f)
                    }
                }
        })
}
})(jQuery);
(function(a){
    a.fn.getData=function(h,g){
        var d,b,e=[];
        if(!(h instanceof Array)){
            alert("getData needs an Array");
            return
        }else{
            if(!g){
                alert("oopsies, I need someone to respond to:: second element");
                return
            }
        }
        d=0;
    b=h.length;
    function f(i){
        a.ajax({
            url:i.url,
            success:function(j){
                switch(i.type){
                    case"js":
                        e.push({
                        data:'\n<script src="'+i.url+'"><\/script>',
                        type:i.type
                        });
                    break;
                    case"json":
                        e.push({
                        data:j,
                        type:i.type,
                        obj:i.obj
                        });
                    break;
                    case"xml":
                        break;
                    case"html":
                        e.push({
                        data:escape(j),
                        type:i.type,
                        obj:i.obj
                        });
                    break;
                    default:
                        alert("getData only accepts js|json|xml. File with the type: "+i.type+", and the url: "+i.url)
                        }
                        c()
                }
            })
    }
    f(h[d]);
    function c(){
    if(d+1<b){
        a(this).trigger("b");
        f(h[++d])
        }else{
        g(e)
        }
    }
}
})(jQuery);/*!
 * imagePreloader jQuery Plugin v0.6.1
 * http://www.stilva.com/
 *
 * Copyright 2011, Thomas.A
 */
(function(d){
    var b="IMAGEPRELOADER_LOADED";
    var e="IMAGEPRELOADER_COMPLETE";
    var a="MODE_BATCH";
    var c="MODE_QUEUED";
    if(d.com){
        if(d.com.stilva){
            d.extend(d.com.stilva,{
                imagePreloader:{}
            })
        }else{
        d.extend(d.com,{
            stilva:{
                imagePreloader:{}
        }
        })
}
}else{
    d.com={
        stilva:{
            imagePreloader:{}
    }
}
}
d.fn.imagePreloader=function(g,f,i){
    var h=this;
    i=(i===null)?a:i;
    return this.each(function(){
        var p=0,o=f.length,s=0,m,j;
        var q=[];
        var n=[];
        function r(l){
            n.push({
                id:l,
                src:f[l],
                ref:new Image()
                });
            d(n[l].ref).bind("load.imagePreloader",{
                i:l
            },k).attr("src",f[l])
            }
            function k(l){
            s++;
            m=n[l.data.i].id;
            j=f[l.data.i];
            d(n[l.data.i].ref).unbind("load.imagePreloader");
            q.push([m,j]);
            if(i===c){
                if(q.length===f.length){
                    h.trigger(e+"."+g,[q]);
                    n=q=""
                    }else{
                    h.trigger(b+"."+g,[Number(m),j]);
                    r(++m)
                    }
                }else{
            if(q.length===f.length){
                h.trigger(e+"."+g,[q]);
                n=q=""
                }else{
                h.trigger(b+"."+g,[Number(m),j])
                }
            }
    }
    for(p;p<((i===a)?o:1);p++){
    r(p)
    }
})
}
})(jQuery);
(function(a){
    a.fn.rotate3d=function(b){
        var c={
            image:null,
            ny:0,
            interval:0,
            scope:this,
            front:null,
            back:null
        };
        
        return this.each(function(){
            if(b){
                a.extend(c,b)
                }
                if(c.image){
                alert("")
                }
                c.scope=this;
            a(this).css({
                webkitTransform:"rotateY(180deg)",
                "webkitBox-sizing":"border-box",
                "webkitTransform-style":"preserve-3d",
                webkitTransition:"all 1.0s linear"
            })
            })
        }
    })(jQuery);
(function(a){
    if(a.com){
        if(a.com.stilva){
            a.extend(a.com.stilva,{
                scroller:{
                    intervalID:null
                }
            })
        }else{
        a.extend(a.com,{
            stilva:{
                scroller:{
                    intervalID:null
                }
            }
        })
}
}else{
    a.com={
        stilva:{
            scroller:{
                intervalID:null
            }
        }
    }
}
a.fn.scroller=function(f,c){
    var b=this;
    var e=a(window);
    f=(f)?f*1000:1000;
    var d={
        ease:"easeInExpo",
        offset:0,
        measurement:"offset",
        onComplete:null,
        onUpdate:null
    };
    
    return this.each(function(j){
        if(c){
            a.extend(d,c)
            }
            if(a.com.stilva.scroller.intervalID){
            clearInterval(a.com.stilva.scroller.intervalID)
            }
            var i=0;
        var h=e.scrollTop();
        var g=b[d.measurement]().top-d.offset;
        a.com.stilva.scroller.intervalID=setInterval(function(){
            i+=41;
            e.scrollTop(a.easing[d.ease]("",i,h,g-h,f));
            if(i>f){
                clearInterval(a.com.stilva.scroller.intervalID);
                a.com.stilva.scroller.intervalID=null;
                e.scrollTop(g);
                if(d.onComplete instanceof Function){
                    d.onComplete()
                    }
                }
        },41)
    })
}
})(jQuery);
(function(a){
    a.fn.unselectable=function(){
        if(!a.browser.msie){
            this.css({
                "-moz-user-select":"-moz-none",
                "-khtml-user-select":"none",
                "-webkit-user-select":"none",
                "-o-user-select":"none",
                "user-select":"none"
            })
            }else{
            this.bind("dragstart selectstart",function(b){
                b.preventDefault()
                })
            }
        }
})(jQuery);
(function(a){
    a.fn.getHiddenDimensions=function(e){
        var d=this,f={
            position:"absolute",
            visibility:"hidden",
            display:"block"
        },g={
            width:0,
            height:0,
            innerWidth:0,
            innerHeight:0,
            outerWidth:0,
            outerHeight:0
        },c=d.parents().andSelf().not(":visible"),e=(e==null)?false:e;
        var b=[];
        c.each(function(){
            var h={};
            
            for(var i in f){
                h[i]=this.style[i];
                this.style[i]=f[i]
                }
                b.push(h)
            });
        g.width=d.width();
        g.outerWidth=d.outerWidth(e);
        g.innerWidth=d.innerWidth();
        g.height=d.height();
        g.innerHeight=d.innerHeight();
        g.outerHeight=d.outerHeight(e);
        c.each(function(k){
            var h=b[k];
            for(var j in f){
                this.style[j]=h[j]
                }
            });
    return g
    }
}(jQuery));
var Section,Contactus,Technical,Products,Gallery,Projects,Banner,Menu,About,Gallas;
var win;
var _show="main";
var intro_button;
var section,contactus,technical,products,gallery,projects,banner,menu,about;
var _ignoreScroll=false;
var console=console?console:{
    log:function(){}
};

onInit=function(){
    Section=Objs("com.stilva.jwi.section.Section");
    // Menu=Objs("com.stilva.jwi.utils.Menu");
    // Gallas=Objs("com.stilva.jwi.section.Gallas");
    // Contactus=Objs("com.stilva.jwi.section.Contactus");
    Banner=Objs("com.stilva.jwi.section.Banner");
    // About=Objs("com.stilva.jwi.section.About");
    // Projects=Objs("com.stilva.jwi.section.Projects");
    // Gallery=Objs("com.stilva.jwi.section.Gallery");
    // Products=Objs("com.stilva.jwi.section.Products");
    // Technical=Objs("com.stilva.jwi.section.Technical");
    // $.address.state("/");
    // intro_button=jQuery("#intro-button");
    // intro_button.bind("click",onIntroButtonHandler);
    section=new Section("section");
    // menu=new Menu();
    // contactus=new Contactus("contact-us");
    banner=new Banner("main",jQuery("section#main"));
    // about=new About("about",jQuery("section#about"));
    // projects=new Projects("project");
    // gallery=new Gallery("gallery",_imgs);
    // products=new Products("products");
    // technical=new Technical("technical");
    win=jQuery(window);
    win.bind("scroll",onScrollHandler);
    win.bind("resize.intro",onIntroResizeHandler);
    jQuery(document).bind("mousemove.intro",onIntroMouseHandler);
    onIntroResizeHandler(null);
    jQuery("#contact-us-button a").bind("click",function(a){
        a.preventDefault();
        contactus.show(0)
        });
    menu.init(jQuery("div#nav-wrapper"));
    menu.addMenus("#menu-about","#menu-project","#menu-gallery","#menu-products","#menu-technical");
    intro_button.find("> a").css({
        display:"block",
        opacity:"0"
    }).animate({
        opacity:1
    },400);
    if(_URL.length>0){
        onIntroButtonHandler({
            preventDefault:function(){}
        })
    }
};

onIntroButtonHandler=function(a){
    a.preventDefault();
    intro_button.unbind("click",onIntroButtonHandler);
    win.unbind("resize.intro",onIntroResizeHandler);
    jQuery(document).unbind("mousemove.intro",onIntroMouseHandler);
    jQuery("#nav-background").css({
        display:"block",
        top:win.height()
        }).animate({
        top:"0px"
    },250,"easeOutExpo",onBlackened)
    };
    
onBlackened=function(){
    jQuery("body").css("background-color","#EDEEF0");
    jQuery("#intro-image img").css("display","none");
    jQuery("#intro-button").css("display","none");
    gallery.init(jQuery("section#gallery"));
    technical.init(jQuery("section#technical"));
    products.init(jQuery("section#products"));
    projects.init(jQuery("section#project"));
    banner.init();
    about.init();
    jQuery("#intro-image").delay(250).animate({
        height:"0"
    },300,"easeOutExpo");
    jQuery("#nav-wrapper nav").css({
        height:jQuery("#nav-background").height()
        }).delay(100).animate({
        height:"0px"
    },300,"easeOutExpo",function(){
        jQuery("#nav-wrapper nav div").each(function(c,b){
            jQuery(b).css("display","block")
            })
        }).delay(275).animate({
        height:"215px"
    },375,"easeInExpo");
    jQuery("#nav-background").delay(100).animate({
        height:"0px"
    },300,"easeOutExpo").delay(275).animate({
        height:"215px"
    },375,"easeInExpo",onMenuShown);
    if(_URL.length===0){
        banner.show()
        }else{
        section.setCurrent(banner);
        var a=_URL.split("/");
        a.shift();
        a[0]=a[0];
        menu._onMouseHandler({
            type:"externalChange",
            pathNames:a,
            preventDefault:function(){}
        },_URL)
    }
    $.address.externalChange(function(b){
    menu._onMouseHandler(b,b.value)
    });
jQuery("section#about div.dotted-line").css({
    height:(50)+"px"
}).find("div.black-block").last().css({
    top:"64px"
});
win.bind("resize",onResizeHandler);
    onResizeHandler(null)
    };
    
onMenuShown=function(){
    jQuery("#header").css("display","block");
    jQuery("#awwwards a").css("visibility","visible");
    jQuery("#nav-background").delay(1000).animate({
        height:"77px"
    },450,"easeOutExpo");
    jQuery("#nav-wrapper nav").delay(1000).animate({
        height:"77px"
    },450,"easeOutExpo",function(){
        jQuery("#nav-wrapper nav").bind("mouseenter mouseleave",onMenuHandler)
        })
    };
    
onMenuHandler=function(a){
    switch(a.type){
        case"mouseenter":
            jQuery("#nav-background").stop(false).animate({
            height:"215px"
        },450,"easeOutExpo");
        jQuery("#nav-wrapper nav").stop(false).animate({
            height:"215px"
        },450,"easeOutExpo");
        break;
        case"mouseleave":
            jQuery("#nav-background").stop(false).animate({
            height:"77px"
        },450,"easeOutExpo");
        jQuery("#nav-wrapper nav").stop(false).animate({
            height:"77px"
        },450,"easeOutExpo");
        break
        }
        };

var Menu=Objs("com.stilva.jwi.utils.Menu",{
    win:null,
    self:null,
    selected:null,
    selectedTargetID:null,
    pattern:/menu-([\w]+)/ig,
    currentID:0,
    items:[],
    initialize:function(){
        var a=this
        },
    init:function(a){
        var b=this;
        this.self=a;
        this.self.find("> nav div#menu-logo").bind("click",function(c){
            b._onMouseHandler(c)
            })
        },
    select:function(c){
        var b=0;
        var a=this.items.length;
        c=(c.substr(0,1)==="#")?c:"#"+c;
        this.unselect();
        for(b;b<a;b++){
            if(this.items[b]===c){
                this.currentID=b;
                this.selected=jQuery(this.items[b]).find("> h1");
                this.selected.removeClass("selected").css("background-position","0 77px").addClass("selected");
                this.selected.animBackground(0.25,{
                    y:0,
                    ease:"easeInExpo"
                });
                break
            }
        }
        },
unselect:function(){
    if(this.selected){
        this.selected.animBackground(0.25,{
            y:77,
            onComplete:function(){
                this.removeClass("selected")
                }
            });
    this.selected=null
    }
},
addMenu:function(a){
    this.items.push(a)
    },
addMenus:function(){
    var b=0,a=arguments.length,c=this;
    for(b;b<a;b++){
        this.items.push(arguments[b]);
        this.self.find("div"+arguments[b]+" ul > li > a").bind("click",function(d){
            c._onMouseHandler(d,jQuery(this).attr("rel"))
            });
        this.self.find("div"+arguments[b]+" > h1").bind("click",function(d){
            c._onMouseHandler(d)
            })
        }
    },
setValue:function(a){
    $.address.value(a)
    },
_onMouseHandler:function(f,a){
    f.preventDefault();
    var c=this,b;
    this.pattern.lastIndex=0;
    if(f.type!=="externalChange"){
        b=(f.currentTarget.id==="menu-logo")?"main":this.pattern.exec(f.currentTarget.offsetParent.id)[1]
        }else{
        b=(f.pathNames.length===0)?"main":f.pathNames[0]
        }
        var d=section.getFromID(b);
    a=(!a)?d.self.find("nav.sub-menu > ul > li > a").first().attr("rel"):a;
    if(f.type!=="externalChange"){
        if(!a){
            a="/"
            }
            this.setValue(a)
        }
        if(section.getCurrent()&&d!==section.getCurrent()){
        this.select("#menu-"+b);
        section.getCurrent().bind(Section.SECTION_HIDDEN,(d.show).call(d,a));
        section.getCurrent().hide()
        }else{
        if(d===section.getCurrent()){
            (d.show).call(d,a)
            }
        }
}
});
var Section=Objs("com.stilva.jwi.section.Section",{
    _ID:"",
    minHeight:0,
    yOffset:200,
    self:null,
    sub_selected:null,
    initialize:function(a){
        if(!Section.COLLECTION){
            Section.COLLECTION={};
            
            Section.EVENT_LISTENERS={};
            
            Section.SECTION_HIDDEN="SECTION_HIDDEN";
            Section.SECTION_SHOWN="SECTION_SHOWN"
            }
            this._ID=a;
        Section.COLLECTION[a]=this
        },
    init:function(c,b){
        var a=this;
        this.self=c;
        this.self.find("nav.sub-menu > ul li a").live("click dummyClick",function(d){
            d.preventDefault();
            a._onSubMenuHandler(d)
            });
        Cufon.replace("div.dotted-line a.canvasgroup",{
            fontFamily:"avenir",
            hover:"true"
        })
        },
    trigger:function(e,f){
        var c=Section.EVENT_LISTENERS.ename;
        if(!c||c===undefined){
            return
        }
        var d=0,b=c.length;
        for(d;d<b;d++){
            if(c[d]){
                c[d](f)
                }
            }
        },
bind:function(a,b){
    if(Section.EVENT_LISTENERS.ename){
        Section.EVENT_LISTENERS.ename.push(b)
        }else{
        Section.EVENT_LISTENERS.ename=[b]
        }
    },
unbind:function(e){
    var c=Section.EVENT_LISTENERS.ename;
    if(!c){
        return
    }
    var d=0,b=c.length;
    for(d;d<b-1;d++){
        c[d]=c[d+1]
        }
        if(c.length>1){
        c.pop()
        }else{
        Section.EVENT_LISTENERS.ename=null
        }
        return
},
resize:function(b){
    var a=this.minHeight+this.yOffset;
    jQuery("body").css({
        height:(win.height()<a?a:win.height())+"px"
        })
    },
getCurrent:function(){
    return Section.CURRENT
    },
setCurrent:function(a){
    Section.CURRENT=a
    },
getFromID:function(a){
    return Section.COLLECTION[a]
    },
show:function(e){
    var b=this;
    console.log("Section::show",e);
    this.trigger(Section.SECTION_SHOWN,{
        currentTarget:this
    });
    if(this.sub_selected&&this.sub_selected.attr("rel")===e){
        return
    }
    var c=new RegExp(this._ID+"/([^/]+)","ig");
    var d=c.exec(e);
    if(d){
        var a=this.self.find('nav.sub-menu > ul > li > a[rel="/'+d[0]+'"]');
        a.trigger("dummyClick")
        }
        if(this.getCurrent()===this){
        return
    }
    this.self.css({
        top:(screen.height-200)+"px",
        display:"block"
    }).animate({
        top:this.yOffset+"px"
        },750,"easeOutExpo",function(){
        b.setCurrent(b)
        });
    this.resize()
    },
hide:function(){
    var a=this;
    Section.CURRENT=null;
    if(this.sub_selected){
        this.sub_selected.removeClass("selected");
        this.sub_selected=null
        }
        this.self.animate({
        top:(-this.self.height())+"px"
        },750,"easeOutExpo",function(){
        a.unbind(Section.SECTION_HIDDEN);
        a.trigger(Section.SECTION_HIDDEN,{
            currentTarget:a
        })
        })
    },
_onSubMenuHandler:function(c){
    var b=jQuery(c.currentTarget);
    var a=b.attr("rel");
    if(b.hasClass("selected")){
        return
    }
    if(c.type==="click"||c.currentTarget!==c.target){
        $.address.value(a)
        }
        if(this.sub_selected){
        this.sub_selected.removeClass("selected")
        }
        this.sub_selected=jQuery(c.currentTarget);
    this.sub_selected.removeClass("selected").addClass("selected");
    Cufon.replace("nav.sub-menu ul li a",{
        hover:"true"
    })
    }
});
var Banner=Objs("com.stilva.jwi.section.Banner","com.stilva.jwi.section.Section",{
    yOffset:0,
    banner:null,
    height:490,
    currentNb:0,
    swapInterval:0,
    innerInterval:0,
    initInterval:0,
    transform:null,
    initHover:false,
    IE7XOffset:0,
    initialize:function(c,b){
        Banner.$super.initialize.call(this,c);
        var a=this;
        this.minHeight=805;
        this.currentNb=Math.round(Math.random()*2);
        this.self=b;
        this.self.find("div.dotted-line").css({
            height:(50)+"px"
        }).find("div.black-block").last().css({
            top:"24px"
        });
        this.transform={
            WebkitTransform:"-webkit-transform",
            MozTransform:"-moz-transform",
            OTransform:"-o-transform",
            msTransform:"-ms-transform",
            transform:"transform"
        }
    },
attachListeners:function(){
    var a=this;
    this.swapInterval=setInterval(function(){
        a.initAnimation()
        },10000)
    },
removeListeners:function(){
    console.log("removeLIsteners called");
    clearInterval(this.swapInterval);
    clearInterval(this.innerInterval);
    clearInterval(this.initInterval)
    },
init:function(){
    this.dispImages()
    },
dispImages:function(){
    var d=2,b=3,c;
    var a=["left","middle","right"];
    for(;d>=0;d--){
        c='\r\n\t<div class="img-menu">\r\n\t\t<h1>'+_banner_json[this.currentNb][a[d]].name;
        c+="</h1>\r\n\t\t<h2>"+_banner_json[this.currentNb][a[d]].type;
        c+='</h2>\r\n\t</div>\r\n\t<img class="bw-image" src="'+_banner_json[this.currentNb][a[d]].bwImage;
        c+='">\r\n\t<img class="big-image" src="'+_banner_json[this.currentNb][a[d]].colourImage+'">\r\n';
        jQuery("section#main div.wrapper div#img-"+(d+1)).append(c)
        }
        Cufon.replace("h1, h2",{
        fontFamily:"avenir"
    })
    },
show:function(){
    if(this.getCurrent()&&this.getCurrent()._ID==="main"){
        return
    }
    Banner.$super.show.call(this,0);
    this.removeListeners();
    this.attachListeners();
    var a=this;
    this.initInterval=setInterval(function(){
        console.log("show initAnimation() called");
        a.initAnimation()
        },this.initHover?1500:2500)
    },
hide:function(){
    Banner.$super.hide.call(this);
    jQuery("div#animation-container").html("");
    this.removeListeners()
    },
initAnimation:function(){
    clearInterval(this.initInterval);
    var d=this,e=(this.currentNb+1===3)?0:this.currentNb+1;
    currentPics=[_banner_json[this.currentNb].left.bwImage,_banner_json[this.currentNb].middle.bwImage,_banner_json[this.currentNb].right.bwImage];
    newPics=[_banner_json[e].left.bwImage,_banner_json[e].middle.bwImage,_banner_json[e].right.bwImage];
    var c=jQuery('<div id="rotating-content"></div>').appendTo(jQuery('<div id="tmp-container"></div>').appendTo("div#animation-container"));
    var b=0,a=currentPics.length;
    for(;b<a;b++){
        c.append("<div "+(b===0?'id="first-facet"':"")+'class="facet"><div class="left-facet"><img src="'+currentPics[b]+'"></div><div class="right-facet"><img src="'+newPics[b]+'"></div></div><div class="facet"><div class="left-facet"><img src="'+currentPics[b]+'"></div><div class="right-facet"><img src="'+newPics[b]+'"></div></div>')
        }
        jQuery("div.banner-image").css({
        visibility:"hidden"
    });
    if($.browser.version==="7.0"&&$.browser.msie){
        this.IE7XOffset=-405;
        jQuery(".facet:odd div img").css({
            position:"absolute",
            left:"-162px"
        })
        }
        jQuery(".facet").each(function(f){
        jQuery(this).css({
            left:(f*162+d.IE7XOffset)+"px",
            top:(f*-528)+"px"
            })
        });
    jQuery(".facet div.right-facet").css({
        zIndex:-777
    });
    if(Modernizr.csstransforms3d){
        this.swap3DImages()
        }else{
        this.swapImages()
        }
    },
swapImages:function(){
    var b=1,a=this;
    this.innerInterval=setInterval(function(){
        jQuery(".facet:nth-child("+b+") div.left-facet img").delay(b*100).animate({
            opacity:0
        },550,"easeInExpo",function(){
            jQuery(this).css("visibility","hidden")
            });
        b++;
        if(b===7){
            clearInterval(a.innerInterval);
            setTimeout(a.imagesSwapped,1100)
            }
        },165)
},
swap3DImages:function(){
    var b=1,a=this;
    this.innerInterval=setInterval(function(){
        jQuery(".facet:nth-child("+b+")").css({
            visibility:"visible"
        });
        jQuery(".facet:nth-child("+b+") div.left-facet").css(a.transform[Modernizr.prefixed("transform")],"rotateY(180deg)");
        jQuery(".facet:nth-child("+b+") div.right-facet").css(a.transform[Modernizr.prefixed("transform")],"rotateY(0deg)");
        b++;
        if(b===7){
            clearInterval(a.innerInterval);
            setTimeout(a.imagesSwapped,650)
            }
        },165)
},
imagesSwapped:function(){
    var a=window.banner;
    if(!a.initHover){
        a.self.find("div#img-1").bind("click mouseenter mouseleave",["img-1"],function(b){
            a._onBannerHandler(b)
            });
        a.self.find("div#img-2").bind("click mouseenter mouseleave",["img-2"],function(b){
            a._onBannerHandler(b)
            });
        a.self.find("div#img-3").bind("click mouseenter mouseleave",["img-3"],function(b){
            a._onBannerHandler(b)
            });
        a.initHover=true
        }
        window.banner.currentNb=(window.banner.currentNb+1===3)?0:window.banner.currentNb+1;
    jQuery("div.banner-image").css({
        visibility:"visible"
    });
    jQuery("section#main div.wrapper div#img-1").html("");
    jQuery("section#main div.wrapper div#img-2").html("");
    jQuery("section#main div.wrapper div#img-3").html("");
    window.banner.dispImages();
    jQuery("div#animation-container").animate({
        opacity:"0"
    },750,"easeInExpo",function(){
        jQuery(this).html("");
        jQuery(this).animate({
            opacity:"1"
        },0)
        })
    },
_onBannerHandler:function(h){
    var c=0,f=this;
    var d=jQuery(h.currentTarget);
    var i=d.find("img.bw-image").first();
    switch(h.type){
        case"click":
            var b,g=/\/([^\/]+)\/([^\/]+)\/?([\w-_]+)?/ig;
            if(this.banner!==null){
            switch(h.data[0]){
                case"img-1":
                    b=_banner_json[this.currentNb].left.slug;
                    break;
                case"img-2":
                    b=_banner_json[this.currentNb].middle.slug;
                    break;
                case"img-3":
                    b=_banner_json[this.currentNb].right.slug;
                    break
                    }
                    var a=g.exec(unescape(b));
            if(a){
                window.menu._onMouseHandler({
                    type:"click",
                    currentTarget:{
                        offsetParent:{
                            id:"#menu-"+a[1]
                            }
                        },
                preventDefault:function(){}
                },a[0])
        }
        }
    break;
case"mouseenter":
    if(f.banner){
    c=350
    }
    f.banner=d;
this.removeListeners();
    d.css("z-index",77);
    i.stop(true).animate({
    opacity:0,
    "z-index":77
},350);
d.stop(true).delay(350+c).animate({
    width:648
},350,function(){
    f._onBannerImageShown(d.find("div.img-menu"))
    });
break;
case"mouseleave":
    this.removeListeners();
    this.attachListeners();
    f._onBannerImageHide(d.find("div.img-menu"));
    d.stop(true).animate({
    width:324
},350);
i.stop(true).delay(350).animate({
    opacity:1,
    "z-index":7
},350,function(){
    d.css("z-index",7);
    f.banner=(f.banner&&f.banner.attr("id")===d.attr("id"))?null:f.banner
    });
break
}
},
_onBannerImageShown:function(c){
    c.parent().css({
        cursor:"pointer"
    });
    var b=[c.find("h1"),c.find("h2")];
    for(var a=0;a<2;a++){
        b[a].stop(true).css({
            display:"block",
            opacity:"0"
        }).animate({
            opacity:1
        },125).animate({
            "line-height":b[a].css("font-size")
            },125,"easeOutExpo")
        }
    },
_onBannerImageHide:function(c){
    c.parent().css({
        cursor:"auto"
    });
    var b=[c.find("h1"),c.find("h2")];
    for(var a=0;a<2;a++){
        b[a].stop(true).animate({
            "line-height":"50px"
        },125).animate({
            opacity:0
        },125,function(){
            jQuery(this).css({
                display:"none",
                opacity:"0"
            })
            })
        }
    }
});
var About=Objs("com.stilva.jwi.section.About","com.stilva.jwi.section.Section",{
    initialize:function(c,a){
        jQuery("section#about div.wrapper").append(innerShiv(_about_html));
        About.$super.initialize.call(this,c);
        var b=this;
        this.minHeight=702;
        this.self=a;
        this.self.find("nav.sub-menu > ul li a").live("click",function(d){
            d.preventDefault();
            b._onSubMenuHandler(d)
            })
        },
    init:function(){
        this.self.find("div.column").last().css({
            margin:0,
            padding:0
        })
        },
    show:function(b){
        About.$super.show.call(this,b);
        var a=this.self.find('nav.sub-menu ul li a[rel="'+b+'"]').removeClass("selected").addClass("selected");
        if(a.get(0)){
            Cufon.replace(a.get(0))
            }
        }
});
var Gallas=Objs("com.stilva.jwi.section.Gallas","com.stilva.jwi.section.Section",{
    json:null,
    currentFilter:null,
    currentProject:null,
    pattern:/\/project\/([^\/]+)\/?([\w-_]+)?/ig,
    width:972,
    height:490,
    projectImgNb:0,
    currentImgNb:0,
    sub_menus:[],
    _prevProjectID:"",
    _leftArrow:null,
    _rightArrow:null,
    initialize:function(a){
        Gallas.$super.initialize.call(this,a);
        this.minHeight=616
        },
    init:function(d,c){
        Gallas.$super.init.call(this,d,c);
        this.self=d;
        for(var b in this.json){
            this._fillElements(b,this.json[b])
            }
            var a=this;
        this.self.find("div.galla-content div.filter-galla").each(function(f,e){
            jQuery(this).css({
                top:-f*a.height,
                left:a.width*f
                })
            });
        this._leftArrow=this.self.find("nav.img-nav li.img-nav-left a").bind("click",{
            dir:"left"
        },function(f){
            a._onArrowHandler(f)
        });
        this._rightArrow=this.self.find("nav.img-nav li.img-nav-right a").bind("click",{
            dir:"right"
        },function(f){
            a._onArrowHandler(f)
            });
        this.self.find("div.dotted-line").css({
            height:(50)+"px"
        }).find("div.black-block").last().css({
            top:"18px"
        });
        this.self.find("div.filter-galla ul.galla-list li a").bind("click dummyClick",function(f){
            a._onProjectMouseHandler(f)
            })
        },
    show:function(b){
        Gallas.$super.show.call(this,b);
        this.pattern.lastIndex=0;
        var a=this.pattern.exec(b);
        if(a[2]){
            this.self.find("div.galla-content div#"+a[1]+' ul.galla-list li a[rel="'+b+'"]').trigger("dummyClick")
            }
        },
hide:function(){
    Gallas.$super.hide.call(this)
    },
_fillElements:function(f,b){
    if(b.type==="galla"){
        this.sub_menus.push("/"+this._ID+"/"+f);
        this.self.find("div.wrapper nav.sub-menu ul").append('<li><a href="/'+this._ID+"/"+f+'" rel="/'+this._ID+"/"+f+'">'+b.title+"</a></li>");
        var d=jQuery('<div id="'+f+'" class="filter-galla images-preloader-gif"></div>').appendTo(this.self.find("div.galla-content")).append('<ul class="galla-list"></ul>\n<ul class="galla-info"></ul>\n<ul class="galla-images"></ul>');
        var c=d.find("ul.galla-list"),e=d.find("ul.galla-state"),j=0;
        var g,h=0,i=jQuery("section#project").css("display");
        jQuery("section#project").css({
            display:"block"
        });
        for(var a in b){
            if(b[a] instanceof Object){
                g=jQuery('<li><a href="/'+this._ID+"/"+f+"/"+a+'" rel="/'+this._ID+"/"+f+"/"+a+'"><span>'+b[a].title+"</span>&nbsp;"+b[a].state+"</a></li>").appendTo(c);
                h=Math.max(h,g.find("a > span").outerWidth()-15)
                }
            }
        if(h>0){
        c.find("li > a > span").width(h)
        }
        jQuery("section#project").css({
        display:i
    })
    }
},
filter:function(a,c,d){
    this._leftArrow.css({
        opacity:0,
        display:"none"
    });
    if(jQuery("div#"+c+" ul.galla-list li").length>1){
        this._rightArrow.stop(true).css({
            opacity:0,
            display:"none"
        }).delay(850).css({
            display:(c==="all-projects")?"none":"block"
            }).animate({
            opacity:(c==="all-projects")?"0":"1"
            },350,"easeInExpo")
        }else{
        this._rightArrow.stop(true).animate({
            opacity:"0"
        },350,"easeInExpo").css({
            opacity:0,
            display:"none"
        })
        }
        if(d){
        this.self.find("div.galla-content").first().css({
            left:a*-this.width
            });
        this._onSubSectionShown(c)
        }else{
        var b=this;
        this.self.find("div.galla-content").first().stop(true).delay(350).animate({
            left:a*-this.width
            },750,"easeInExpo",function(){
            b._onSubSectionShown(c)
            })
        }
    },
_hideProject:function(f,c){
    var g,e,a,b=this;
    this.pattern.lastIndex=0;
    g=this.pattern.exec(f.attr("rel"));
    e=this.self.find("div#"+g[1]+" ul.galla-info li");
    e.animate({
        top:(-e.height())+"px"
        },550,"easeInExpo");
    this.self.find("#pji-nav li").animate({
        opacity:0
    },550,"easeInExpo");
    a=this.self.find("div#"+g[1]+" ul.galla-images");
    a.animate({
        opacity:0
    },550,"easeInExpo",function(){
        b.self.find("div#"+g[1]+" ul.galla-info").html("");
        a.find("> li").remove();
        f.removeClass("showing");
        b._showProject(c)
        })
    },
_showProject:function(a){
    var f,b,h,n=this;
    this.pattern.lastIndex=0;
    f=this.pattern.exec(a.attr("rel"));
    var j=this.json[f[1]][f[2]].images,m=[],k;
    var e=0,c=j.length;
    for(;e<c;e++){
        m.push(j[e].thumb)
        }
        b=this.self.find("div#"+f[1]+" ul.galla-info");
    var g=jQuery("<li><p>"+unescape(this.json[f[1]][f[2]].text).replace(/\+/g," ")+"</p></li>").appendTo(b);
    g.css({
        top:b.height()+"px"
        }).animate({
        top:b.height()+"px"
        },((g.height()===0)?1000:0),function(){
        jQuery(this).animate({
            top:(162-g.height())/2+"px"
            },550,"easeOutExpo")
        });
    h=this.self.find("div#"+f[1]+" ul.galla-images");
    h.css("right","0px");
    if(this._prevProjectID){
        h.unbind("IMAGEPRELOADER_LOADED.PROJECTS_"+this._prevProjectID);
        h.unbind("IMAGEPRELOADER_COMPLETE.PROJECTS_"+this._prevProjectID)
        }
        e=0;
    this._prevProjectID=f[2];
    h.bind("IMAGEPRELOADER_COMPLETE.PROJECTS_"+this._prevProjectID,function(o,i){
        if(i.length-1!==e){
            return
        }
        e++;
        n.projectImgNb=i.length-1;
        var d="";
        k=jQuery('<li style="top:'+(-n.projectImgNb*490)+"px; left:"+(n.projectImgNb*648)+'px;"><img id="_project_img_'+n.projectImgNb+'" src="'+i[n.projectImgNb][1]+'">'+d+"</li>").appendTo(h);
        n._addFullScreen(k,j[i.length-1].bigImg);
        if(n.projectImgNb>0){
            n._rightArrow.css({
                display:"block"
            }).animate({
                opacity:1
            },250,function(){
                jQuery(this).css("filter","none")
                })
            }
            h.css({
            width:(648*(n.projectImgNb+1))+"px"
            })
    });
    h.bind("IMAGEPRELOADER_LOADED.PROJECTS_"+this._prevProjectID,function(d,o,i){
        if(o!=e){
            return
        }
        e++;
        n.projectImgNb=o;
        if(o>0){
            n._rightArrow.css({
                display:"block"
            }).animate({
                opacity:1
            },250,function(){
                jQuery(this).css("filter","none")
                })
            }
            k=jQuery('<li style="top:'+(-o*490)+"px; left:"+(o*648)+'px;"><img id="_project_img_'+o+'" src="'+i+'"></li>').appendTo(h);
        h.css({
            width:(648*(o+1))+"px"
            });
        n._addFullScreen(k,j[o].bigImg)
        });
    h.animate({
        opacity:1
    },550,"easeInExpo");
    this.self.find("#pji-nav li").delay(250).animate({
        opacity:1
    },550,"easeOutExpo");
    a.addClass("showing");
    this.currentImgNb=0;
    this._leftArrow.animate({
        opacity:0
    },250,function(){
        jQuery(this).css({
            display:"none"
        })
        });
    this._rightArrow.css({
        display:"none"
    });
    this.currentFilter=this.self.find("div#"+f[1]);
    this.currentFilter.find("ul.galla-images").css({
        left:"324px"
    });
    h.imagePreloader("PROJECTS_"+this._prevProjectID,m,"MODE_QUEUED")
    },
_addFullScreen:function(a,b){
    var c=jQuery('<a href="'+b+'" class="full-screen-image">Fullscreen</a>').insertAfter(a.find("img"));
    c.fancybox({
        titleShow:false,
        transitionIn:"fade",
        transitionOut:"fade",
        centerOnScroll:true,
        overlayOpacity:0.95,
        overlayColor:"#000000",
        padding:"0"
    })
    },
_onSubMenuHandler:function(b){
    b.type="dummyClick";
    Gallas.$super._onSubMenuHandler.call(this,b);
    var a=jQuery(b.currentTarget).attr("rel");
    this.pattern.lastIndex=0;
    var c=this.pattern.exec(a);
    if(c&&c[1].length>0){
        this._onSubSectionShown(c[1])
        }
    },
_onSubSectionShown:function(a){
    this.currentImgNb=0;
    this.currentFilter=this.self.find("div#"+a);
    this.currentFilter.find("ul.galla-images").css({
        left:"324px"
    });
    this.projectImgNb=this.currentFilter.find("ul.galla-images li").length-1
    },
_onArrowHandler:function(a){
    a.preventDefault();
    switch(a.data.dir){
        case"left":
            this.currentImgNb=(this.currentImgNb-1>=0)?this.currentImgNb-1:0;
            break;
        case"right":
            this.currentImgNb=(this.currentImgNb+1<=this.projectImgNb)?this.currentImgNb+1:this.currentImgNb;
            break
            }
            if(this.currentImgNb==this.projectImgNb){
        this._rightArrow.stop(true).animate({
            opacity:0
        },250,function(){
            jQuery(this).css("display","none")
            });
        this._leftArrow.css("display","block").stop(true).animate({
            opacity:1
        },250)
        }else{
        if(this.currentImgNb===0){
            this._leftArrow.stop(true).animate({
                opacity:0
            },250,function(){
                jQuery(this).css("display","none")
                });
            this._rightArrow.css("display","block").stop(true).animate({
                opacity:1
            },250)
            }else{
            this._leftArrow.css({
                display:"block",
                opacity:1
            });
            this._rightArrow.css({
                display:"block",
                opacity:1
            })
            }
        }
    console.log(this.currentFilter);
this.currentFilter.find("ul.galla-images").stop(true).animate({
    left:324+this.currentImgNb*(-648)+"px"
    },800,"easeInSine")
},
_onProjectMouseHandler:function(c){
    c.preventDefault();
    var a=jQuery(c.currentTarget);
    if(a.hasClass("showing")){
        return
    }
    if(c.type==="click"){
        menu.setValue(a.attr("rel"))
        }
        var b=a.offsetParent().find('> li > a[class="showing"]');
    if(b[0]){
        this._hideProject(b,a)
        }else{
        this._showProject(a)
        }
    }
});
var Projects=Objs("com.stilva.jwi.section.Projects","com.stilva.jwi.section.Gallas",{
    json:null,
    currentFilter:null,
    currentProject:null,
    pattern:/\/project\/([^\/]+)\/?([\w-_]+)?/ig,
    width:972,
    height:490,
    projectImgNb:0,
    currentImgNb:0,
    sub_menus:[],
    _leftArrow:null,
    _rightArrow:null,
    allProjectsCurrent:0,
    allProjectsMax:0,
    initialize:function(a){
        Projects.$super.initialize.call(this,a);
        this.json=window._projects_json
        },
    init:function(b,a){
        Projects.$super.init.call(this,b,a);
        this.self=b;
        this.self.find("div#all-projects-wrapper > ul").each(function(e,d){
            var c=jQuery(d);
            c.css({
                left:(e*324)+"px",
                top:"0px"
            });
            c.children("li:first").children("h1").css({
                "margin-top":"0px"
            })
            })
        },
    onInnerScroll:function(f){
        var b="left",d=this;
        if(f){
            b=(f.currentTarget.id==="all-projects-nav-next")?"right":"left"
            }
            var c=jQuery("div#all-projects-wrapper > ul.all-projects");
        var a=((3-(this.allProjectsMax)%3+(this.allProjectsMax))/3);
        switch(b){
            case"left":
                this.allProjectsCurrent=(this.allProjectsCurrent>0)?this.allProjectsCurrent-1:0;
                break;
            case"right":
                this.allProjectsCurrent=(this.allProjectsCurrent<a-1)?this.allProjectsCurrent+1:a-1;
                break
                }
                c.each(function(g,e){
            jQuery(e).animate({
                left:(g*324-d.allProjectsCurrent*972)+"px"
                })
        });
        jQuery("div#all-projects-nav-next").css({
            display:(this.allProjectsCurrent===a-1)?"none":"block"
            });
        jQuery("div#all-projects-nav-prev").css({
            display:(this.allProjectsCurrent===0)?"none":"block"
            })
        },
    _fillElements:function(d,a){
        if(a.type==="list"){
            var c=0;
            this.sub_menus.push("/project/"+d);
            this.self.find("div.wrapper nav.sub-menu ul").append('<li><a href="/project/'+d+'" rel="/project/'+d+'">'+a.title+"</a></li>");
            var b=jQuery('<div id="all-projects-wrapper" class="filter-galla images-preloader-gif">').appendTo(this.self.find("div#project-content"));
            var g=0,f=0;
            var c=(jQuery('<ul class="all-projects"></ul>').appendTo(b));
            var h;
            for(;f<a.data.length;f++){
                h=a.data[f];
                for(g=0;g<h.length;g++){
                    c.append("<li>"+h[g]+"</li>")
                    }
                    c=(jQuery('<ul class="all-projects"></ul>').appendTo(b))
                }
                this.allProjectsMax=a.data.length;
            var k=this;
            var e=jQuery('<div id="all-projects-nav"></div>').appendTo(b);
            jQuery('<div id="all-projects-nav-next">NEXT</div>').appendTo(e).bind("click",function(i){
                k.onInnerScroll(i)
                });
            jQuery('<div id="all-projects-nav-prev">PREVIOUS</div>').appendTo(e).bind("click",function(i){
                k.onInnerScroll(i)
                })
            }else{
            Projects.$super._fillElements.call(this,d,a)
            }
        },
_onSubMenuHandler:function(c){
    Projects.$super._onSubMenuHandler.call(this,c);
    var a=jQuery(c.currentTarget).attr("rel");
    this.pattern.lastIndex=0;
    var d=this.pattern.exec(a);
    var b=0;
    l=this.sub_menus.length;
    for(b;b<l;b++){
        if(this.sub_menus[b]===a){
            this.filter(b,d[1],(window.section.getCurrent()!==window.projects));
            if(b===this.sub_menus.length-1){
                this.onInnerScroll(null)
                }else{
                this.self.find("div#"+d[1]+" ul.galla-list li a").first().trigger("dummyClick")
                }
                break
        }
    }
    }
});
var Gallery=Objs("com.stilva.jwi.section.Gallery","com.stilva.jwi.section.Section",{
    win:null,
    doc:null,
    json:null,
    thumbs:null,
    pattern:/\/gallery\/([^\/]+)\/?([\w-_]+)?/ig,
    leftBtn:null,
    rightBtn:null,
    loading:false,
    currentSlug:"",
    hideInterval:0,
    ratio:0,
    columns:0,
    ie7XOffset:0,
    scrollThumbs:0,
    thumbWidth:162,
    button:null,
    ln:0,
    scrollTop:0,
    sectionVisited:[],
    initialize:function(b,a){
        Gallery.$super.initialize.call(this,b);
        this.minHeight=641;
        this.json=a;
        this.win=jQuery(window);
        this.doc=jQuery(document);
        this.thumbs=jQuery("#thumbnails")
        },
    init:function(d,c){
        Gallery.$super.init.call(this,d,c);
        var b=this,a=0;
        this.ie7XOffset=(jQuery("html").hasClass("ie7"))?451:0;
        this.self=d;
        this.self.find("div.dotted-line").css({
            height:(50)+"px"
        });
        this.scrollTop=this.self.offset().top;
        this.button=this.self.find("div.scroll-background div.black-block");
        this.leftBtn=this.self.find("li.gallery-nav-left a");
        this.rightBtn=this.self.find("li.gallery-nav-right a");
        this.doc.bind("mouseup.gallery",function(f){
            b._onMouseHandler(f)
            });
        this.leftBtn.bind("click.gallery-nav",function(f){
            f.preventDefault();
            b._onNavHandler(f,"left")
            });
        this.rightBtn.bind("click.gallery-nav",function(f){
            f.preventDefault();
            b._onNavHandler(f,"right")
            });
        if(!Modernizr.touch){
            this.button.bind("mousedown.gallery",function(f){
                b._onMouseHandler(f)
                })
            }else{
            this.button.bind("touchstart.gallery touchmove.gallery touchend.gallery",function(f){
                f.preventDefault();
                b._onTouchHandler(f.type,f.originalEvent.touches[0]||f.originalEvent.changedTouches[0])
                })
            }
            jQuery(".scroll-background").bind("click.gallery",function(f){
            b._onMouseClick(f)
            });
        this.self.unselectable();
        this.resize();
        a=Math.floor(win.width()/2);
        this.self.find("nav.gallery-nav li.gallery-nav-left").css({
            width:a
        });
        this.self.find("nav.gallery-nav li.gallery-nav-right").css({
            width:(win.width()-a)
            })
        },
    show:function(a){
        Gallery.$super.show.call(this,a);
        this.pattern.lastIndex=0
        },
    hide:function(){
        Gallery.$super.hide.call(this);
        clearInterval(this.hideInterval)
        },
    resize:function(){
        Gallery.$super.resize.call(this);
        this.self.find("nav.gallery-nav li a").css({
            visibility:(this.columns<=6)?"hidden":"visible"
            });
        if(this.self){
            var a;
            if(!this.loading){
                a=Math.floor((win.width()-972)/2);
                this.self.find("nav.gallery-nav li.gallery-nav-left").css({
                    width:a
                });
                this.self.find("nav.gallery-nav li.gallery-nav-right").css({
                    width:(win.width()-972-a)
                    })
                }else{
                a=Math.floor(win.width()/2);
                this.self.find("nav.gallery-nav li.gallery-nav-left").css({
                    width:a
                });
                this.self.find("nav.gallery-nav li.gallery-nav-right").css({
                    width:(win.width()-a)
                    })
            }
        }
        this._onMagnet()
    },
_preload:function(b){
    var c=0,e=0,a,d=this,g=[],f=this.json[b];
    this.ln=this.json[b].length;
    for(c;c<this.ln;c++){
        g.push(f[c][0])
        }
        this.self.unbind("IMAGEPRELOADER_LOADED.GALLERY");
    this.self.unbind("IMAGEPRELOADER_COMPLETE.GALLERY");
    this.self.bind("IMAGEPRELOADER_COMPLETE.GALLERY",function(i,h){
        jQuery("div#gallery-preloader").css({
            "background-position":"0 128px"
        });
        jQuery("nav.gallery-nav li a").css({
            display:"block"
        });
        jQuery("section#gallery div#gallery-preloader").css({
            display:"none"
        });
        d._show(b)
        });
    this.self.bind("IMAGEPRELOADER_LOADED.GALLERY",function(h,j,i){
        a=34+Math.floor(j/(d.ln-1)*94);
        jQuery("div#gallery-preloader").css({
            "background-position":"0 "+a+"px"
            })
        });
    jQuery("div#gallery-preloader").css({
        display:"block",
        "background-position":"0 34px"
    });
    this.self.imagePreloader("GALLERY",g,"MODE_QUEUED")
    },
_onSubMenuHandler:function(c){
    var b=jQuery(c.currentTarget);
    this.pattern.lastIndex=0;
    var a=this.pattern.exec(b.attr("rel"))[1];
    b.offsetParent().find("li > a.selected").removeClass("selected");
    Gallery.$super._onSubMenuHandler.call(this,c);
    b.addClass("selected");
    this.self.find("div.scroll-background").css({
        visibility:"hidden"
    });
    this._hide(a)
    },
_show:function(a){
    var b=0,e=0;
    this.loading=false;
    this.currentSlug=a;
    this.ln=this.json[a].length;
    var h=this.json[a];
    var d=this.self.find("div#gallery-content > div#thumbnails");
    d.find("div.gallery-thumbnail img").unbind(".gallery-thumbnail",this._onMouseHoverHandler);
    d.html('<div class="gallery-thumbnail" style="top:'+(this.thumbWidth*(b%3))+"px; left:"+e*this.thumbWidth+'px;"><a href="'+(h[b][1])+'" rel="gallery-thumbnails"><img src="'+(h[b][0])+'"/><img class="hidden-absolute-image" src="'+(h[b][0])+'"/></a></div>');
    for(;b<this.ln;b++){
        d.append('<div class="gallery-thumbnail" style="top:'+(this.thumbWidth*(b%3))+"px; left:"+e*this.thumbWidth+'px;"><a href="'+(h[b][1])+'" rel="gallery-thumbnails"><img src="'+(h[b][0])+'"/><img  class="hidden-absolute-image" src="'+(h[b][0])+'"/></a></div>');
        e=(b%3==2)?++e:e
        }
        d.find("div.gallery-thumbnail img").bind("mouseenter.gallery-thumbnail mouseleave.gallery-thumbnail",this._onMouseHoverHandler);
    var f=(e<5)?this.ln+(3-this.ln%3)+(5-e)*3:this.ln+(3-this.ln%3);
    for(;b<f;b++){
        d.append('<div class="gallery-thumbnail" style="top:'+(this.thumbWidth*(b%3))+"px; left:"+e*this.thumbWidth+'px;"><img src="http://www.jwilouvres.com.au/img/unavailable.jpg"/></div>');
        e=(b%3==2)?++e:e
        }
        d.find("div.gallery-thumbnail a[rel=gallery-thumbnails]").fancybox({
        titleShow:false,
        transitionIn:"fade",
        transitionOut:"fade",
        centerOnScroll:true,
        overlayOpacity:0.95,
        overlayColor:"#000000",
        padding:"0"
    });
    this.columns=e;
    this.scrollThumbs=((this.thumbWidth*this.columns)-972)/this.thumbWidth;
    this.self.find("div.scroll-background").css({
        visibility:(this.scrollThumbs>0)?"visible":"hidden"
        });
    this.self.find("div#gallery-content div#thumbnails").css({
        width:(e*this.thumbWidth)+"px"
        });
    var g=Math.round((this.win.width()-972)/2),c=this;
    this.self.find("nav.gallery-nav ul > li.gallery-nav-left").stop(true).delay(450).animate({
        width:g+"px"
        },750,"easeOutExpo");
    this.self.find("nav.gallery-nav ul > li.gallery-nav-right").stop(true).delay(450).animate({
        width:Math.round(this.win.width()-972-g)+"px"
        },750,"easeOutExpo",function(){
        c._onMagnet();
        c.resize()
        });
    if(this.scrollThumbs>0){
        this.ratio=Math.floor((this.thumbWidth*this.scrollThumbs)/2)/972
        }
        this._onMagnet()
    },
_onMouseHoverHandler:function(b){
    var a=jQuery(b.currentTarget);
    switch(b.type){
        case"mouseenter":
            a.stop(true).animate({
            opacity:"0"
        },225,"easeInQuad");
        break;
        case"mouseleave":
            a.stop(true).animate({
            opacity:"1"
        },225,"easeOutQuint");
        break
        }
        },
_hide:function(a){
    this.loading=true;
    var b=0,e=Math.round(this.win.width()/2),d=this.columns,c=this;
    clearInterval(c.hideInterval);
    this.self.find("nav.gallery-nav ul > li.gallery-nav-left").stop(true).animate({
        width:e+"px"
        },750,"easeOutExpo");
    this.self.find("nav.gallery-nav ul > li.gallery-nav-right").stop(true).animate({
        width:(this.win.width()-e)+"px"
        },750,"easeOutExpo",this._onHidden.call(this,a))
    },
_onHidden:function(b){
    var d=this;
    d._onMouseMove(0,true);
    var c=0,a=jQuery("div#thumbnails div.gallery-thumbnail").length;
    d.hideInterval=setInterval(function(){
        if(c>=a){
            clearInterval(d.hideInterval);
            d._preload(b)
            }
            jQuery("div#thumbnails div.gallery-thumbnail").eq(Math.round(Math.random()*(a-c))).remove();
        ++c
        },1000/a)
    },
_onMagnet:function(){
    var a=Math.floor(this.ratio*902);
    if(a%(902/this.scrollThumbs)<(902/this.scrollThumbs)/2){
        this._onMouseMove(a-a%(902/this.scrollThumbs))
        }else{
        this._onMouseMove(a+((902/this.scrollThumbs)-Math.abs(a%(902/this.scrollThumbs))))
        }
    },
_onMouseHandler:function(c){
    var b=this;
    var a=c.offsetX||c.layerX;
    switch(c.type){
        case"mousedown":
            if(c.target.className==="scroll-background"){
            return
        }
        this.doc.unbind("mouseup.gallery");
            this.doc.bind("mouseup.gallery",function(d){
            b._onMouseHandler(d)
            });
        this.doc.unbind("mousemove.gallery");
            this.doc.bind("mousemove.gallery",function(d){
            b._onMouseMove(d.pageX-(b.win.width()-972)/2-a)
            });
        break;
        case"mouseup":
            this.doc.unbind("mouseup.gallery");
            this.doc.unbind("mousemove.gallery");
            this._onMagnet();
            break
            }
        },
_onTouchHandler:function(d,f){
    var c=this;
    var b=f.pageX;
    switch(d){
        case"touchstart":
            if(f.target.className==="scroll-background"){
            return
        }
        break;
        case"touchend":
            this._onMagnet();
            break;
        case"touchmove":
            var a=(f.pageX>902)?902:f.pageX;
            this.button.css({
            left:(a)+"px"
            });
        this.ratio=(f.pageX/(972-70));
            this.thumbs.css({
            left:Math.floor((win.width()-972)/2-(this.ratio*((this.thumbWidth*this.columns)-972)))
            });
        break
        }
        },
_onMouseMove:function(a,b){
    a=(a<0)?0:((a>902)?902:a);
    b=(b===undefined)?true:b;
    this.button.css({
        left:(a-this.ie7XOffset)+"px"
        });
    this.ratio=(a/(972-70));
    this.thumbs.stop(true,b).animate({
        left:Math.floor((win.width()-972)/2-(this.ratio*((this.thumbWidth*this.columns)-972)))
        },350,"easeOutCirc")
    },
_onMouseClick:function(b){
    if(b.target.className==="black-block"){
        return
    }
    var a=(b.offsetX<0)?0:((b.offsetX>902)?902:b.offsetX);
    this.ratio=(a/(972-70));
    this._onMagnet(a)
    },
_onNavHandler:function(c,b){
    var a=this.ratio*902;
    switch(b){
        case"right":
            this._onMouseMove(a+(902/this.scrollThumbs),false);
            break;
        case"left":
            this._onMouseMove(a-(902/this.scrollThumbs),false);
            break;
        case"mouseover":
            break
            }
        }
});
var Products=Objs("com.stilva.jwi.section.Products","com.stilva.jwi.section.Gallas",{
    pattern:/\/products\/([^\/]+)\/?([\w-_]+)?/ig,
    initialize:function(a){
        Products.$super.initialize.call(this,a);
        this.json=window._products_json
        },
    init:function(b,a){
        Products.$super.init.call(this,b,a);
        this.self=b
        },
    _onSubMenuHandler:function(d){
        Products.$super._onSubMenuHandler.call(this,d);
        this.pattern.lastIndex=0;
        var a=jQuery(d.currentTarget).attr("rel");
        var f=this.pattern.exec(a);
        console.log(a,f);
        var c=0;
        l=this.sub_menus.length;
        for(c;c<l;c++){
            if(this.sub_menus[c]===a){
                this.filter(c,f[1],(window.section.getCurrent()!==window.products));
                var b=this.self.find("div#"+f[1]+" ul.galla-list li");
                if(b.find("a.showing").length<1||d.target!==d.currentTarget){
                    this.self.find("div#"+f[1]+" ul.galla-list li a").first().trigger("dummyClick")
                    }
                    break
            }
        }
        },
_onProjectMouseHandler:function(c){
    Products.$super._onProjectMouseHandler.call(this,c);
    var b=jQuery(c.currentTarget).attr("rel");
    this.pattern.lastIndex=0;
    var d=this.pattern.exec(b);
    var a=this.json[d[1]][d[2]].pdf;
    this.self.find("div#"+d[1]+" ul li#pdf_link").remove();
    if(a){
        jQuery('<li id="pdf_link"><a href="'+a+'" target="_blank">PDF</a></li>').appendTo(this.self.find("div#"+d[1]+" ul.galla-list"))
        }
    }
});
var Technical=Objs("com.stilva.jwi.section.Technical","com.stilva.jwi.section.Section",{
    json:null,
    sub_menus:["/technical/environment","/technical/design-awards"],
    initialize:function(a){
        Technical.$super.initialize.call(this,a);
        this.minHeight=692
        },
    init:function(d,c){
        d.find(".wrapper").html(innerShiv(_technical_html));
        Technical.$super.init.call(this,d,c);
        this.self=d;
        this.self.find("div.dotted-line").css({
            height:(50)+"px"
        }).find("div.black-block").last().css({
            top:"22px"
        });
        var a=this.self.css("display");
        this.self.css({
            display:"block"
        });
        this.self.find(".wrapper").height(40+this.self.find("div.filter-technical").height());
        var b;
        this.self.find("div.filter-technical").each(function(f,e){
            b=jQuery(e);
            b.css({
                left:(f*972)+"px"
                });
            if($.browser.msie&&($.browser.version==="7.0"||$.browser.version==="8.0")){
                b.find("div.column").last().css({
                    margin:"0",
                    padding:"0"
                })
                }
            });
    this.self.css({
        display:a
    });
    jQuery("section#technical div.filter-technical > div").each(function(f,e){
        if((f+1)%3===0){
            jQuery(e).css({
                margin:0,
                padding:0
            })
            }
        })
},
_onSubMenuHandler:function(b){
    Technical.$super._onSubMenuHandler.call(this,b);
    var a=0;
    l=this.sub_menus.length;
    for(a;a<l;a++){
        if(this.sub_menus[a]===jQuery(b.currentTarget).attr("rel")){
            this._show(a,(window.section.getCurrent()!==window.technical))
            }
        }
    },
show:function(a){
    Technical.$super.show.call(this,a)
    },
hide:function(){
    Technical.$super.hide.call(this)
    },
_show:function(a,c){
    var b;
    this.self.find("div.filter-technical").each(function(e,d){
        b=jQuery(this);
        if(c){
            b.css({
                left:((e*972)-(a*973))+"px"
                })
            }else{
            b.delay(550).animate({
                left:((e*972)-(a*973))+"px"
                })
            }
        })
},
_onMouseHandler:function(b){
    var a=this;
    b.preventDefault()
    }
});
var Contactus=Objs("com.stilva.jwi.section.Contactus","com.stilva.jwi.section.Section",{
    email:/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/,
    initialize:function(a){
        Contactus.$super.initialize.call(this,a);
        this.minHeight=728;
        var b=this;
        jQuery("div#submit-button a").bind("click",function(c){
            c.preventDefault();
            b.onCheckContactForm(c)
            });
        jQuery("div#contact-us div.button").bind("click",function(c){
            c.preventDefault();
            b.onCloseHandler(c)
            })
        },
    show:function(){
        var a=this;
        win.scrollTop(0);
        if(jQuery("#pop-background").filter(":animated").length>0){
            return
        }
        jQuery("div#form-status").removeClass("sending").removeClass("sent").css({
            display:"none"
        });
        jQuery("div#contact-us-content").find("input").val("");
        jQuery("div#contact-us-content").find("textarea").first().val("");
        jQuery("div#contact-us-content").find("input").removeClass("erroneous");
        jQuery("div#contact-us-content").find("textarea").first().removeClass("erroneous");
        this._show()
        },
    hide:function(){},
    onCheckContactForm:function(f){
        var c,g,d="post=form",b=this,a=0;
        this.email.lastIndex=0;
        jQuery("div#contact-us-content").find("input").each(function(h,e){
            c=jQuery(this);
            g=c.offsetParent();
            c.removeClass("erroneous");
            if(g.hasClass("required")&&!c.val()){
                a++;
                c.addClass("erroneous")
                }else{
                if(g.hasClass("email-address")&&!b.email.exec(c.val())){
                    a++;
                    c.addClass("erroneous")
                    }
                }
            d+="&"+c.attr("id")+"="+escape(c.val())
            });
    c=jQuery("div#contact-us-content").find("textarea").first().removeClass("erroneous");
    if(c.val().length<1){
        c.removeClass("erroneous").addClass("erroneous");
        a++
    }
    d+="&msg="+escape(c.val());
    if(a===0){
        this._sendForm(d)
        }
    },
_sendForm:function(a){
    jQuery("div#form-status").removeClass("sending").removeClass("sent").addClass("sending").css({
        display:"block"
    });
    $.ajax({
        type:"POST",
        url:"/email.php",
        data:a,
        error:function(b,d,c){},
        success:function(){
            jQuery("div#form-status").removeClass("sendimg").addClass("sent")
            }
        })
},
_resize:function(a){
    jQuery("div#contact-us").css({
        top:"200px",
        left:(win.width()-972)/2+"px"
        });
    jQuery("#pop-background").css({
        height:Math.max(jQuery(document).height(),jQuery(window).height(),document.documentElement.clientHeight),
        width:win.width()
        })
    },
onCloseHandler:function(){
    this._hide()
    },
_show:function(b){
    var a=this;
    this._resize(null);
    win.bind("resize.contact_us",this._resize);
    jQuery("#pop-background").animate({
        height:win.height(),
        top:win.height()
        },0,function(){
        var c=jQuery("div#contact-us").height();
        jQuery("#pop-background").css({
            display:"block"
        });
        jQuery("div#contact-us").css({
            height:"0px",
            display:"block"
        }).delay(500).animate({
            height:c+"px"
            },500,"easeInExpo")
        }).animate({
        top:"0px"
    },500,"easeOutExpo",function(){
        a._resize(null)
        })
    },
_hide:function(){
    var b=this;
    var c=jQuery("div#contact-us");
    win.unbind("resize.contact_us",this._resize);
    var a=c.height();
    c.animate({
        height:0
    },500,"easeInExpo",function(){
        c.css({
            display:"none",
            height:a
        })
        });
    jQuery("#pop-background").delay(600).animate({
        top:win.height()+"px"
        },375,"easeInQuint",function(){
        jQuery("#pop-background").css({
            height:"0px",
            display:"none"
        })
        })
    }
});
onIntroMouseHandler=function(a){
    intro_button.stop(true).animate({
        top:a.pageY-45,
        left:a.pageX-45
        },550,"easeOutExpo")
    };
    
onIntroResizeHandler=function(a){
    jQuery("body").css({
        overflow:"hidden",
        width:win.width(),
        height:win.height()
        });
    jQuery("#intro-button").css("left",(win.width()-90)/2);
    jQuery("#intro-image").css({
        left:(win.width()-jQuery("#intro-image").width())/2
        })
    };
    
onResizeHandler=function(a){
    jQuery("body").css({
        width:win.width()>972?win.width():972
        });
    if(section.getCurrent()){
        section.getCurrent().resize.call(section.getCurrent(),a)
        }
    };

onScrollHandler=function(a){
    a.preventDefault()
    };
jQuery.noConflict();	